home *** CD-ROM | disk | FTP | other *** search
/ Strip Blackjack / Strip Blackjack - Volume 1.iso / pc / lisag / 00055.ls < prev    next >
Encoding:
Text File  |  1994-12-07  |  3.8 KB  |  182 lines

  1. on start
  2.   global S, dlast, ulast, matrix, umax, dmax, uoffset, doffset, totalu, totald, exu, totalux, stay, edx, totaldx, over
  3.   if S = 8 then
  4.     go(90)
  5.   end if
  6.   set over to 0
  7.   set stay to 0
  8.   set exu to 0
  9.   set edx to 0
  10.   set totalux to 0
  11.   set totaldx to 0
  12.   set totalu to 0
  13.   set totald to 0
  14.   set uoffset to 1
  15.   set doffset to 10
  16.   set umax to []
  17.   set dmax to []
  18.   repeat with i = 2 to 22
  19.     puppetSprite(i, 1)
  20.   end repeat
  21.   repeat with i = 4 to 10
  22.     set the visible of sprite i to 0
  23.   end repeat
  24.   repeat with i = 13 to 19
  25.     set the visible of sprite i to 0
  26.   end repeat
  27.   repeat with i = 25 to 28
  28.     set the visible of sprite i to 0
  29.   end repeat
  30.   repeat with i = 20 to 22
  31.     set the visible of sprite i to 1
  32.   end repeat
  33.   set ulast to 0
  34.   set dlast to 0
  35.   set matrix to []
  36.   repeat with i = 1 to 52
  37.     add(matrix, i)
  38.   end repeat
  39.   puppetSprite(36, 1)
  40.   set the visible of sprite 36 to 1
  41.   updateStage()
  42.   addu()
  43.   addu()
  44.   addd()
  45.   addd()
  46. end
  47.  
  48. on addu
  49.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, exu, totalux, Y
  50.   set x to 0
  51.   repeat while getOne(matrix, x) = 0
  52.     set x to random(52)
  53.   end repeat
  54.   deleteAt(matrix, getPos(matrix, x))
  55.   set ulast to ulast + 1
  56.   set the castNum of sprite (uoffset + ulast) to x
  57.   set the visible of sprite (uoffset + ulast) to 1
  58.   add(umax, x)
  59.   set totalu to totmax(umax)
  60.   if cvalue(x) = 1 then
  61.     set exu to exu + 10
  62.   end if
  63.   set totalux to totalu + exu
  64.   updateStage()
  65.   delx()
  66. end
  67.  
  68. on addd
  69.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, stay, edx, totaldx, Y
  70.   set x to 0
  71.   repeat while getOne(matrix, x) = 0
  72.     set x to random(52)
  73.   end repeat
  74.   deleteAt(matrix, getPos(matrix, x))
  75.   set dlast to dlast + 1
  76.   if count(dmax) > 0 then
  77.     set the castNum of sprite (doffset + dlast - 1) to getAt(dmax, count(dmax))
  78.     if cvalue(getAt(dmax, count(dmax))) = 1 then
  79.       set edx to edx + 10
  80.     end if
  81.   end if
  82.   set totald to totmax(dmax)
  83.   set totaldx to totmax(dmax) + edx
  84.   if (totaldx <= 16) or ((totald <= 16) and (totaldx > 21)) then
  85.     set the castNum of sprite (doffset + dlast) to 53
  86.     set the visible of sprite (doffset + dlast) to 1
  87.     add(dmax, x)
  88.   end if
  89.   updateStage()
  90. end
  91.  
  92. on cvalue x
  93.   set yu to the name of cast x
  94.   set yi to char 2 of yu
  95.   if voidp(value(yi)) then
  96.     return 10
  97.   else
  98.     return value(yi)
  99.   end if
  100. end
  101.  
  102. on delx
  103.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, totalux
  104.   if totalu > 21 then
  105.     lose()
  106.     exit
  107.   end if
  108.   if (totalu = 21) or (totalux = 21) then
  109.     win()
  110.     exit
  111.   end if
  112.   if count(umax) = 5 then
  113.     win()
  114.     exit
  115.   end if
  116. end
  117.  
  118. on win
  119.   global over, S
  120.   set over to 1
  121.   set the visible of sprite 36 to 0
  122.   go(11)
  123. end
  124.  
  125. on lose
  126.   global over
  127.   set over to 1
  128.   set the visible of sprite 20 to 0
  129.   set the visible of sprite 21 to 0
  130.   go(12)
  131. end
  132.  
  133. on totmax x
  134.   set yu to 0
  135.   repeat with i in x
  136.     set yu to yu + cvalue(i)
  137.   end repeat
  138.   return yu
  139. end
  140.  
  141. on stay
  142.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, stay, totalux, totaldx, edx, exu, totalub, totaldb
  143.   set stay to 0
  144.   repeat while (totaldx <= 16) or ((totald <= 16) and (totaldx > 21))
  145.     addd()
  146.   end repeat
  147.   if totald > 21 then
  148.     win()
  149.     exit
  150.   end if
  151.   if (totald = 21) or (totaldx = 21) then
  152.     lose()
  153.     exit
  154.   end if
  155.   calcbest()
  156.   if totalub >= totaldb then
  157.     win()
  158.   else
  159.     lose()
  160.   end if
  161. end
  162.  
  163. on calcbest
  164.   global totald, totalu, totaldx, totalux, edx, exu, totaldb, totalub
  165.   set totaldb to totaldx
  166.   set totalub to totalux
  167.   repeat with i = 1 to edx / 10
  168.     if totaldb > 21 then
  169.       set totaldb to totaldb - 10
  170.       next repeat
  171.     end if
  172.     exit repeat
  173.   end repeat
  174.   repeat with i = 1 to exu / 10
  175.     if totalub > 21 then
  176.       set totalub to totalub - 10
  177.       next repeat
  178.     end if
  179.     exit repeat
  180.   end repeat
  181. end
  182.